﻿
Partial Class App_Controls_PrivateMessage
    Inherits MyUI.UserControlBaseApp

    Protected CurrAccount As mDB.Account

    Public Property ToAccountId() As Integer
        Get
            Return Me.ViewState("ToAccountId")
        End Get
        Set(ByVal value As Integer)

            Me.ViewState("ToAccountId") = value
            'SetDataPage()
        End Set
    End Property

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        CurrAccount = CurrUser.CurrAccount

    End Sub

    Protected Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender

        'If Not Me.IsLoaded Then
        '    If CurrAccount IsNot Nothing Then
        '        SetDataPage()
        '        Me.IsLoaded = True
        '    End If

        'End If

    End Sub

    Public Sub SetDataPage()

        Me.PostPrivate.Visible = False

        If Me.ToAccountId <> 0 Then
            Dim f = CurrAccount._Tab_Account_Link(GloukDB._Account_Link.Type.FOLLOWER, Me.ToAccountId).ToObj
            If f IsNot Nothing Then
                Me.PostPrivate.Visible = True
                Me.PostPrivate.ToAccount = DB.TAB.Account.GetByPK(Me.ToAccountId).Username '   CurrAccount.Username
                Me.PostPrivate.PostText = ""
                Me.PostPrivate.SetDataPage()

            End If
        End If


        'Dim ListPrivateMess = Me.ListPrivateMess
        'Dim PnlPrivateMess = UI.ListDataItem.GetPanel(Row, "PnlPrivateMess")
        Dim dt = DB.TAB.Private_Post.REL.Private_Post.ToAccount.BY.Private_Post.Account_Id(CurrAccount.Id, ToAccountId).ToDataTable
        UI.ListData.Bind(ListPrivateMess, dt, {})
        'PnlPrivateMess.Visible = True

        '$("#mydiv").scrollTop($("#mydiv")[0].scrollHeight);
        'Dim div_PrivateMess = UI.ListDataItem.GetControl(Of Control)(Row, "div_PrivateMess") 'itemPlaceholder
        'Me.AddJScript(SF("$('#{0}').scrollTop($('#{0}')[0].scrollHeight);", div_PrivateMess.ClientID))

        'Me.AddJScript(SF("alert($('#{0}'));", div_PrivateMess.ClientID))

    End Sub
End Class
